<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="h" uri="/WEB-INF/config/tag/feonix-tags.tld"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色权限设置</title>
<h:head pagetype="dialog" validity="true" iconfont="true" tree="true"></h:head>
<script>
$(function() {
	var zNodes = ${tree};
	var setting = {
			callback: {
				beforeClick: beforeClick
			}
	};
	$('#tree').tree(setting, zNodes);
});

function beforeClick(treeId, treeNode, clickFlag){
	if (treeNode.isDisabled){
		return false;
	}
	return (treeNode.id != 0);
}

function submitChecked(){
	var treeObj = $.fn.zTree.getZTreeObj("tree");
	var nodes = treeObj.getSelectedNodes();
	if(!nodes.length > 0){
		alert("请先选择一个父级权限！");
		return;
	}
	getDialog().dialog('options').callback(nodes[0]);
	closeDialog();
}
</script>
</head>
<style>
.rightspan {
	width:120px;  
	float:left; 
	padding:5px 20px;
	overflow:hidden;
	white-space:nowrap;
	text-overflow: ellipsis;
}
</style>
<body>
	<div id="dialog-content" style="padding: 20px 20px 0 20px; overflow: hidden;">
		<ul id="tree" class="ztree"></ul>
	</div>
	<div id="dialog-toolbar">
		<div id="dialog-toolbar-panel">
			<input type="button" class="btn btn-primary" value="确定" onclick="submitChecked();"/> 
			<input type="button" class="btn" value="取消" onclick="closeDialog();" />
		</div>
	</div>
</body>
</html>